/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package customer_cmds;

import appClientHandler.AUPBeanRemote;
import appClientHandler.AUPCustomerRemote;
import commands.CommandAbstractAction;
import commands.ProductCommand;
import commands.QuitCommand;
import commands.StoreCommand;
import customer_jdom.ProductStoreJDOM;
import entities.Cart;
import entities.Commande;
import entities.Product;
import entities.ProductStore;
import general.OptionBase;
import general.OptionName;

import java.io.PrintStream;
import java.util.List;

/**
 *
 * eCOM - Adopte un Presta - Mars-Avril 2013
 * @author Kheira, Jef, William, Tuan-Long
 */
public class TransactionCommand extends CommandAbstractAction 
{
    

        private AUPBeanRemote aupCustomerRemote;

        @Override
	public String getName() 
        {
		return "transaction";
	}

	@Override
	public String getUsage() {
		return "transaction --<action>";
	}

	@Override
	public String getShortDescription() {
		return "Gestion manuelle des transactions";
	}


        public TransactionCommand(AUPBeanRemote aupCustomerRemote) {
            super();
            this.aupCustomerRemote = aupCustomerRemote;
            this.addOption(new OptionBase("begin", true));
            this.addOption(new OptionBase("commit", true));
            this.addOption(new OptionBase("rollback", true));
        }


        public void beginAction()
        {
            try
            {
                //this.aupCustomerRemote.beginTransaction();
            }
            catch (Exception e)
            {
                this.getErr().println("Can not BEGIN transaction");
            }
        }


        public void commitAction()
        {
            try
            {
                //this.aupCustomerRemote.commitTransaction();
            }
            catch (Exception e)
            {
                this.getErr().println("Can not COMMIT transaction");
            }
        }


        public void rollbackAction()
        {
            try
            {
                //this.aupCustomerRemote.rollbackTransaction();
            }
            catch (Exception e)
            {
                this.getErr().println("Can not ROLLBACK transaction");
            }
        }

    @Override
    public void defaultAction(){
        this.getOut().println("Usage : " + this.getUsage());
        this.getOut().println("You need to specify an action");
    }
}
